programming4us
           
 
 
Windows

Windows 7: Troubleshooting Device Problems (part 2) - Displaying a List of Nonworking Devices

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/30/2010 3:13:25 PM

Displaying a List of Nonworking Devices

Device Manager’s icons (discussed in the previous section) are great, but it’s not always convenient to fire up Device Manager to check for problems. To avoid that, use the script in Listing 1, which displays a list of all the problem devices on your system.

Note

The file containing the script in Listing 1—ListNonWorkingDevices.vbs—is available from my website at http://mcfedries.com/Windows7Unleashed/.


Listing 1. Script That Displays a List of a PC’s Nonworking Devices
Option Explicit
Dim strComputer, objWMI, collDevices, objDevice
Dim intDevices, strMessage
'
' Get the WMI object
'
strComputer = "."
Set objWMI = GetObject("winmgmts:\\" & _
strComputer & "\root\cimv2")
'
' Return the collection of nonworking devices on the computer
'
Set collDevices = objWMI.ExecQuery _
("Select * from Win32_PnPEntity " _
& "WHERE ConfigManagerErrorCode <> 0")
'
' Run through each item in the collection
'
intDevices = 0
strMessage = ""
For Each objDevice in collDevices
strMessage = strMessage & "Device Name: " & objDevice.Name & vbCrLf
strMessage = strMessage & "Manufacturer: " & objDevice.Manufacturer & vbCrLf
strMessage = strMessage & "Device ID: " & objDevice.DeviceID & vbCrLf
strMessage = strMessage & "Service: " & objDevice.Service & vbCrLf
strMessage = strMessage & "Error Code: " & objDevice.ConfigManagerErrorCode & vbCrLf
strMessage = strMessage & vbCrLf & vbCrLf
intDevices = intDevices + 1
Next
'
' Display the results
'
If intDevices = 0 Then
WScript.Echo "No non-working devices found!"
Else
WScript.Echo "Found " & intDevices & " non-working device(s):" & _
vbCrLf & vbCrLf & _
strMessage
End If


The script sets up the WMI object and then uses WMI to return the collection of nonworking devices (that is, where the device’s ConfigManagerErrorCode property isn’t 0). A For Each...Next loop goes through each device and stores various data about the device to a string variable, including the device name and ID, and the error code. The script then displays the results, and Figure 3 shows an example.

Figure 3. Sample output from the script in Listing 1.


Table 1 lists the various error codes and what they mean.

Table 1. Error Codes for Nonworking Devices
CodeDescription
0Device is working properly.
1Device is not configured correctly.
2Windows cannot load the driver for this device.
3Driver for this device might be corrupted, or the system may be low on memory or other resources.
4Device is not working properly. One of its drivers or the Registry might be corrupted.
5Driver for the device requires a resource that Windows cannot manage.
6Boot configuration for the device conflicts with other devices.
7Cannot filter.
8Driver loader for the device is missing.
9Device is not working properly. The controlling firmware is incorrectly reporting the resources for the device.
10Device cannot start.
11Device failed.
12Device cannot find enough free resources to use.
13Windows cannot verify the device’s resources.
14Device cannot work properly until the computer is restarted.
15Device is not working properly because of a possible reenumeration problem.
16Windows cannot identify all the resources that the device uses.
17Device is requesting an unknown resource type.
18Device drivers must be reinstalled.
19Failure using the Vloader.
20Registry might be corrupted.
21System failure. If changing the device driver is ineffective, see the hardware documentation. Windows is removing the device.
22Device is disabled.
23System failure. If changing the device driver is ineffective, see the hardware documentation.
24Device is not present, not working properly, or does not have all its drivers installed.
25Windows is still setting up the device, but the installation is incomplete.
26Windows is still setting up the device, but not all the devices drivers were installed or there’s a problem with one of the device drivers.
27Device does not have valid log configuration.
28Device drivers are not installed.
29Device is disabled. The device firmware did not provide the required resources.
30Device is using an IRQ resource that another device is using.
31Device is not working properly. Windows cannot load the required device drivers.
Other -----------------
- Windows 7: Working with Device Security Policies
- Windows Vista : Configuring Network Security - Windows Defender
- Windows 7: Managing Your Hardware with Device Manager (part 4) - Writing a Complete List of Device Drivers to a Text File
- Windows 7: Managing Your Hardware with Device Manager (part 3) - Configuring Windows to Ignore Unsigned Device Drivers
- Windows 7: Managing Your Hardware with Device Manager (part 2) - Working with Device Drivers
- Windows 7: Managing Your Hardware with Device Manager (part 1)
- SOA with .NET and Windows Azure: WCF Extensions - WCF Transactions (part 2)
- SOA with .NET and Windows Azure: WCF Extensions - WCF Transactions (part 1)
- Windows 7: Recovering from a Problem
- Windows 7: Troubleshooting Tools (part 3) - Checking for Solutions to Problems
- Windows 7: Troubleshooting Tools (part 2) - Running the Memory Diagnostics Tool
- Windows 7: Troubleshooting Tools (part 1) - Running the Windows 7 Troubleshooters
- Windows Vista : User Account Control
- Windows 7 : Troubleshooting Strategies - Determining the Source of a Problem (part 3)
- Windows 7 : Troubleshooting Strategies - Determining the Source of a Problem (part 2)
- Windows 7 : Troubleshooting Strategies - Determining the Source of a Problem (part 1)
- Windows 7 : Enabling MAC Address Filtering
- Windows 7 : Changing the Default SSID
- Windows 7 : Disabling Network SSID Broadcasting
- Windows 7 : Encrypting Wireless Signals with WPA
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us